package linkedListExample;
import java.util.List;
import java.util.LinkedList;

public class LinkedListDemo {
    public static void main(String[] args)
    {
        String a = "张三",b = "热烈";
        List<String> list = new LinkedList<String>();
        list.add("欢迎");
        list.add("李四");
        list.add("光临！");
        System.out.println("修改前");
        print(list);
        list.set(1,a);
        System.out.println("修改后");
        print(list);
        list.addFirst(b);
        System.out.println("头插");
        print(list);
    }
    public static void print(List<String> list)
    {
        for(var s:list)
            System.out.print(s);
        System.out.println(); // 换行
    }
}
